#include "fxcc/yml/Serializer.h"
#include "fxcc/core/graph/common/EffectsDesc.h"

using namespace fxcc::yml;
using namespace fxcc::graph::common;

template<>
void Serializer::Encode<EffectDesc>(YAML::Node& node, const EffectDesc& inst)
{
	Encode<fxcc::Base>(node, inst);
	SetVariable<std::string>(node, "m_Name", inst.m_Name);
	SetVariable<std::string>(node, "m_FragPath", inst.m_FragPath);
	SetVariable<fxcc::graph::common::Defines>(node, "m_Defines", inst.m_Defines);
}


template<>
bool Serializer::Decode<EffectDesc>(const YAML::Node& node, EffectDesc& inst)
{
	Decode<fxcc::Base>(node, inst);
	GetVariable<std::string>(node, "m_Name", inst.m_Name);
	GetVariable<std::string>(node, "m_FragPath", inst.m_FragPath);
	GetVariable<fxcc::graph::common::Defines>(node, "m_Defines", inst.m_Defines);
	return true;
}


template<>
void Serializer::Encode<EffectsDesc>(YAML::Node& node, const EffectsDesc& inst)
{
	auto func = [&](const EffectDesc& desc) {return desc.m_Exist; };
	Encode<fxcc::Base>(node, inst);
	SetArrayVariable<EffectDesc>(node, "m_Descs", inst.m_Descs, func);
}


template<>
bool Serializer::Decode<EffectsDesc>(const YAML::Node& node, EffectsDesc& inst)
{
	Decode<fxcc::Base>(node, inst);
	GetArrayVariable<EffectDesc>(node, "m_Descs", inst.m_Descs);
	return true;
}